import request from '@/utils/request'

// 查询部门列表
export function listArea(query) {
  return request({
    url: '/sysArea/area/list',
    method: 'get',
    params: query
  })
}

export function listAreaByDeptOrPart(query) {
  return request({
    url: '/sysArea/area/listAreaByDeptOrPart',
    method: 'get',
    params: query
  })
}
export function listAreabyParetnt(query) {
  return request({
    url: '/sysArea/area/listAreabyParetnt',
    method: 'get',
    params: query
  })
}

export function listByLazyTreePart(query) {
  return request({
    url: '/sysArea/area/listByLazyTreePart',
    method: 'get',
    params: query
  })
}

export function listGoodsOrderIn(query) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/list',
    method: 'get',
    params: query
  })
}


// 根据deptId grade 获取json
export function getAreaJson(query) {
  return request({
    url: '/sysArea/area/getJson',
    method: 'get',
    params: query
  })
}
// 根据deptId grade 获取json
export function getAreaLabels(query) {
  return request({
    url: '/sysArea/area/getAreaLabels',
    method: 'get',
    params: query
  })
}

export function listByLazyTree(query) {
  return request({
    url: '/sysArea/area/listAreaByLazyTree',
    method: 'get',
    params: query
  })
}

export function listAreaByLazyTree(query) {
  return request({
    url: '/sysArea/area/listByLazyTree',
    method: 'get',
    params: query
  })
}

// 查询部门列表（排除节点）
export function listAreaExcludeChild(deptId) {
  return request({
    url: '/sysArea/area/list/exclude/' + deptId,
    method: 'get'
  })
}

// 查询部门详细
export function getArea(deptId) {
  return request({
    url: '/sysArea/area/' + deptId,
    method: 'get'
  })
}

// 查询部门下拉树结构
export function treeselectAll(query) {
  return request({
    url: '/sysArea/area/treeselect',
    method: 'get',
    params: query
  })
}

// 查询部门下拉树结构
export function treeselectAreaAll(query) {
  return request({
    url: '/sysArea/area/treeselectArea',
    method: 'get',
    params: query
  })
}
// 根据角色ID查询部门树结构
export function roleAreaTreeselect(roleId) {
  return request({
    url: '/sysArea/area/roleAreaTreeselect/' + roleId,
    method: 'get'
  })
}

// 新增部门
export function addArea(data) {
  return request({
    url: '/sysArea/area',
    method: 'post',
    data: data
  })
}

// 修改部门
export function updateArea(data) {
  return request({
    url: '/sysArea/area',
    method: 'put',
    data: data
  })
}

// 删除部门
export function delArea(deptId) {
  return request({
    url: '/sysArea/area/' + deptId,
    method: 'delete'
  })
}

export function changeRiskFlag(id, flag) {
  const data = {
    deptId:id,
    riskflag:flag
  }
  return request({
    url: '/sysArea/area/changeRiskflag',
    method: 'post',
    data: data
  })
}

export function addGoodsOrderIn(data) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/insertIn',
    method: 'post',
    data: data
  })
}


export function goodsOrderIn(data) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/insertOrderUpdateArea',
    method: 'post',
    data: data
  })
}
export function goodsOrderInAdd(data) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/add',
    method: 'post',
    data: data
  })
}

export function goodsOrderInUpdate(data) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/edit',
    method: 'put',
    data: data
  })
}

// 修改部门
export function updateGoodsOrderIn(data) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/updateIn',
    method: 'put',
    data: data
  })
}

// 删除
export function delGoodsOrderIn(ids) {
  return request({
    url: '/goodsOrderIn/goodsOrderIn/' + ids,
    method: 'delete'
  })
}

